package com.leyou.item.mapper;

import com.leyou.common.mapper.BaseMapper;
import com.leyou.item.pojo.Brand;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BrandMapper extends BaseMapper<Brand> {

    int insertCategoryBrand(@Param("bid") Long id,@Param("cids") List<Long> cids);

    //根据品牌的id删除中间表中对应的分类的信息
    @Delete("delete from tb_category_brand where brand_id = #{brandId}")
    void deleteCategoryBrand(@Param("brandId") Long id);

    @Select("select ba.* from tb_brand ba inner join tb_category_brand cb on ba.id=cb.brand_id where cb.category_id = #{cid}")
    List<Brand> queryByCategoryId(@Param("cid") Long id);
}